package coder.nav.schedule.action;

import coder.nav.model.bo.NavTaskActionBO;
import coder.nav.service.NavMailService;
import coder.nav.service.NavTaskService;
import coder.nav.service.NavUserService;
import coder.nav.utils.FileUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class NavTaskBaseAction {

    @Autowired
    protected NavUserService userService;
    @Autowired
    protected NavTaskService taskService;
    @Autowired
    protected NavMailService mailService;

    public String title() {
        return "无需提醒";
    }

    public String context() {
        return "";
    }

    public String params() {
        return "";
    }

    public Date executeTime() {
        return null;
    }

    public boolean needToHtml() {
        return true;
    }

    public NavTaskActionBO getEntity(Long userId) {
        NavTaskActionBO entity = new NavTaskActionBO();
        entity.setTitle(title());
        entity.setContext(context());
        entity.setUserId(userId);
        entity.setActionTime(executeTime());
        entity.setNeedToHtml(needToHtml());
        entity.setActionFunction(FileUtils.upperCaseName(this.getClass().getSimpleName()));
        return entity;
    }

    public void addTask(Long userId) {
        NavTaskActionBO entity = this.getEntity(userId);
        taskService.saveTaskAction(entity);
    }

    public void actionTask(NavTaskActionBO task) {

    }

}
